<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.Collection,java.util.Iterator"%>
<%@ page import="java.util.Enumeration,java.util.Objects" %>
<!DOCTYPE html>
<html>
<head>
<title>隐含对象response</title>
<style type="text/css">
table {
  border-collapse: collapse;
}
</style>
</head>
<body>
  session是实现HttpSession接口的实例
  <br>
  <%
      out.print("获取request参数<br>");
      Enumeration<String> names = request.getParameterNames();
      while (names.hasMoreElements()) {
          String element = names.nextElement();
          String val = request.getParameter(element);
          if (Objects.nonNull(val)) {
              out.print(element + "：" + val + "<br>");
          }
      }
      names = request.getParameterNames();
      out.print("获取为request设置的属性<br>");
      while (names.hasMoreElements()) {
          String element = names.nextElement();
          Object val = request.getAttribute(element);
          if (Objects.nonNull(val)) {
              out.print(element + "：" + val + "<br>");
          }
      }
      names = request.getParameterNames();
      out.print("获取为session设置的属性<br>");
      while (names.hasMoreElements()) {
          String element = names.nextElement();
          Object val = session.getAttribute(element);
          if (Objects.nonNull(val)) {
              out.print(element + "：" + val + "<br>");
          }
      }
      out.print("设置响应头<br>");
      response.setHeader("contentType", "text/html;charset=utf-8");
      out.print("添加响应头<br>");
      response.addHeader("gamma", "eclipse");
      out.print("更新指定响应头");
      response.setHeader("gamma", "sunshine");
  %>
  <table border="1">
    <tr>
      <th>当前响应头</th>
      <th>值</th>
    </tr>
  <%
      Collection<String> collection = response.getHeaderNames();
      Iterator<String> iterator = collection.iterator();
      while (iterator.hasNext()) {
          String element = iterator.next();
          out.print("<tr>");
          out.print("<td>" + element + "</td>");
          out.print("<td>" + response.getHeader(element) + "</td>");
          out.print("</tr>");
      }
  %>
  </table>
</body>
</html>
